import { Component, EventEmitter, Input, OnInit, Output } from '@angular/core';
import { Step } from './steps.interfaces';

@Component({
  selector: 'yby-steps',
  templateUrl: './steps.component.html',
  styleUrls: ['./steps.component.scss']
})
export class YbyStepsComponent implements OnInit {

  @Input() stepsWidth = '100%';
  @Input() steps: Step[] = [];
  @Input() current = 1;
  @Input() startIndex = 1;
  @Output() stepChange: EventEmitter<number> = new EventEmitter();

  get hasChange() {
    return this.stepChange.observers.length > 0;
  }

  constructor() { }

  isDisabled(step: Step, index: number) {
    if (typeof step.disabled === 'function') {
      return step.disabled(this.current, index);
    } else {
      return step.disabled;
    }
  }

  ngOnInit(): void {
  }

}
